﻿@{
    ViewBag.Title = ViewBag.siteName + " - Lịch sử đặt hàng";
    ViewBag.Description = ViewBag.htmlDescription;
    ViewBag.Keywords = ViewBag.htmlKeywords;
}
@model PagedList.IPagedList<BDShop.Entities.Order>
@using BDShop.Business;
@using BDShop.Business.Cache;
@using BDShop.Entities;
@using BDShop.Framework.Security;
@using BDShop.Framework.Extensions;
@using BDShop.Utilities.Managers;
@using BDShop.Web;
@using PagedList.Mvc;
@using BDShop.Resources;
<!--Left Part-->
@Html.Partial("Partial/_LeftAccMenu", null)
<!--Left End-->
<!--Middle Part Start-->
<div id="content">
    <!--Breadcrumb Part Start-->
    <div class="breadcrumb"><a href="/">Trang chủ</a> » <a href="/thong-tin-tai-khoan.html">Tài khoản</a> » <a href="#">Lịch sử đặt hàng</a> </div>
    <!--Breadcrumb Part End-->
    <h1>Lịch sử đặt hàng</h1>
    <form enctype="multipart/form-data" method="post" action="#">
        <div class="cart-info">
            <table>
                <thead>
                    <tr>
                        <td class="order">Mã đơn hàng</td>
                        <td class="date">Ngày đặt</td>
                        <td class="name">Chi tiết đơn hàng</td>
                        <td class="total">Tổng tiền</td>
                        <td class="status">Trạng thái</td>

                    </tr>
                </thead>
                <tbody>

                    @foreach (var order in Model)
                    {
                        long productID = OrderDetailService.GetByOrderID(order.ID).First().ProductID;
                        string name = ProductCache.Instance.Get().Where(p => p.ID == productID).FirstOrDefault().Name;
                        string ID =SercurityHelper.ConvertStringToHex(SercurityHelper.Encrypt(order.ID.ToString(), true));
                        <tr>
                            <td class="order"><a href="/chi-tiet-don-hang/@ID" style="font-weight:bold">@order.ID</a></td>
                            <td class="date">@order.DateCreated.ToString("dd/MM/yyyy HH:mm:ss")</td>
                            <td class="name">@name</td>
                            <td class="total">@order.Total.ToCurrencyString(false, true)</td>
                            <td class="status">@FO.ResourceManager.GetEnumString((OrderStatus)order.Status)</td>
                        </tr>
                    }
                    
                </tbody>
            </table>
        </div>
        <div>
            <!--Pagination Part Start-->
                            @if (Model.PageCount > 1)
                            {
                                <div class="paging">
                                    <div class="links">
                                        @Html.PagedListPager(Model, page => Url.Action("OrderHistory", new { page }))
                                    </div>
                                    <div class="results">
                                        Trang @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) của @Model.PageCount
                                    </div>
                                </div>
                            }
                            <!--Pagination Part End-->
        </div>
    </form>
</div>

<!--Middle Part End-->
<div class="clear"></div>
